import request from '@/utils/request'
import service from "@/utils/request";

// 创建角色
export function createRole(data) {
  return request({
    url: '/sa/role/create',
    method: 'post',
    data: data
  })
}

// 更新角色
export function updateRole(data) {
  return request({
    url: '/sa/role/update',
    method: 'put',
    data: data
  })
}

// 删除角色
export function deleteRole(id) {
  return request({
    url: '/sa/role/delete?id=' + id,
    method: 'delete'
  })
}

// 获得角色
export function getRole(id) {
  return request({
    url: '/sa/role/get?id=' + id,
    method: 'get'
  })
}

// 获得角色 分页
export function getRolePage(query) {
  return request({
    url: '/sa/role/page',
    method: 'get',
    params: query
  })
}

// 导出角色  Excel
export function exportRoleExcel(query) {
  return request({
    url: '/sa/role/export-excel',
    method: 'get',
    params: query,
    responseType: 'blob'
  })
}

// 创建角色分类模块配置
export function createRoleFolderModule(data) {
  return request({
    url: '/sa/role-folder-module/create',
    method: 'post',
    data: data
  })
}

// 更新角色分类模块配置表
export function updateRoleFolderModule(data) {
  return request({
    url: '/sa/role-folder-module/update',
    method: 'put',
    data: data
  })
}

export function getRoleFolderModule(roleFolderId) {
  return service({
    url: '/sa/role-folder-module/get?roleFolderId=' + roleFolderId,
    method: 'get'
  })
}

// 创建角色分类人员配置
export function createRoleFolderUser(data) {
  return request({
    url: '/sa/role-folder-user/batchcreate',
    method: 'post',
    data: data
  })
}

export function getRoleFolderUserPage(data) {
  return request({
    url: '/sa/role-folder-user/page',
    method: 'get',
    params: data
  })
}

export function getMyRoleFolderList(authType) {
  let data = {}
  if (!!authType) {
    data.authType = authType
  }
  return request({
    url: '/sa/role-folder-user/person',
    method: 'get',
    params: data
  })
}

export function deleteRoleFolderUser(id) {
  return request({
    url: '/sa/role-folder-user/delete?id=' + id,
    method: 'delete'
  })
}

